package com.pro.system.Repository;

import com.pro.system.entity.Movie;
import com.pro.system.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Repository
public interface UserRepository extends JpaRepository<User,Integer> {
    @Override
    List<User> findAll();


    @Query(value = "select * from users where username = ?1" ,nativeQuery = true)
    User findByName(String name);

    @Modifying
    @Transactional
    @Query(value = "select * from users where username like %?1% " ,nativeQuery = true)
    public List<User> findByNameLike(String name);


}
